﻿using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.ValueGeneration;
using Snowflake.Core;

namespace EFCoreSnowFlakeIdDemo.WebApi.Models
{
    public class SnowflakeIdGenerator : ValueGenerator<long>
    {
        public override bool GeneratesTemporaryValues => false;

        public override long Next(EntityEntry entry)
        {
            var worker = new IdWorker(1, 1);
            long id = worker.NextId();
            return id;
        }
    }
}
